package demo1_图书管理系统;/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 谢忠涵7
 * Date: 2023-12-17
 * Time: 19:18
 */

import java.util.Scanner;

/** * @author xiaoxie
 * @date 2023年12月17日 19:18
 */

public class Main {
    public static User menu() {
        int choice = 0;
        String possWord = "123456";
        System.out.println("请输入你的身份：");
        System.out.println("1.管理员   2.普通用户 ");
        Scanner scan = new Scanner(System.in);
        choice = scan.nextInt();
        scan.nextLine();
        if (choice == 1) {
            System.out.println("请输入密码：");
            int count = 3;
            while (count > 0) {
                String MyPossWord = scan.nextLine();
                if (MyPossWord.equals(possWord)) {
                    count = -1;
                    break;
                } else {
                    --count;
                    System.out.println("密码错误，你还有" + count + "次机会");
                }
            }
            if (count != -1) {
                System.out.println("密码输入错误超过3次，请您24小时后在来");
                System.exit(0);
            }
            return new Admin("admin");
        }
        return new NormalUser("noraluser");
    }
    public static void main(String[] args) {
        BookList bookList = new BookList();
        User user = Main.menu();
        while (true) {
            int choice = user.menu();
            user.doOperation(choice,bookList);
        }
        }
}
